﻿#include <iostream>
#include "JsonSaver.h"


JsonSaver::JsonSaver(std::string filename)
{
	fout.open(filename);
}


JsonSaver::~JsonSaver()
{
	fout.flush();
	fout.close();
	if (s != nullptr) {
		delete s;
	}
}


void JsonSaver::write(Record& r)
{
	nlohmann::json j = r;
	fout << j << std::endl;
}


void JsonSaver::Write(Record& r)
{
	s->write(r);
}

JsonSaver* JsonSaver::s = new JsonSaver("data.json");
